package com.example.controller;

import com.example.pojo.aboutSchool.Schools;
import com.example.pojo.aboutUser.User;
import com.example.service.GeneralService;
import com.example.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/general")
public class GeneralController {
    @Resource
    private GeneralService generalService;

    @GetMapping("/test")
    public Result test(@RequestBody(required = false) Map<String, Object> params) {

        List<Schools> result = generalService.test();

        return Result.success(result);
    }

    @GetMapping("/search")
    public Result search(@RequestParam("keyword") String keyword){
        List<Schools> result = generalService.search(keyword);
        return Result.success(result);
    }


    @PostMapping("/insertCollege")
    public Result insertCollege(@RequestBody Schools schools) {
        generalService.insertCollege(schools);
        return Result.success();
    }

    @PostMapping("/deleteCollege")
    public Result deleteCollege(@RequestBody  Schools schools){
        generalService.deleteCollege(schools);
        return Result.success();
    }

    @PostMapping("/changeCollege")
    public Result changeCollege(@RequestBody Schools schools){
        generalService.changeCollege(schools);
        return Result.success();
    }
}
